cmake_minimum_required(VERSION 3.16)
project(SimpleImplWithLibTorch)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(Torch_DIR /media/tacom/fd1834d9-91ec-45dc-908b-eed1b326caaa/Envs/libtorch_251_cpu/share/cmake/Torch)
set(OpenCV_DIR /media/tacom/fd1834d9-91ec-45dc-908b-eed1b326caaa/Envs/OpenCV460/Binary/lib/cmake/opencv4)
set(CMAKE_PREFIX_PATH /home/tacom/QtEnv/6.7.2/gcc_64/lib/cmake)

#set(Torch_DIR D:/Development/Envs/libtorch_251_cpu/share/cmake/Torch)
#set(OpenCV_DIR D:/Development/Envs/OpenCV460/Binary/x64/vc16/lib)
#set(CMAKE_PREFIX_PATH D:/Development/Envs/QtEnv/6.7.0/msvc2019_64/lib/cmake)

find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
message(STATUS ${TORCH_CXX_FLAGS})
add_executable(SimpleImplWithLibTorch
    main.cpp
)
target_precompile_headers(${PROJECT_NAME}
    PUBLIC
        TorchInclude.h
)
target_link_libraries(SimpleImplWithLibTorch
        Qt${QT_VERSION_MAJOR}::Core
        ${TORCH_LIBRARIES}
        ${OpenCV_LIBS}
)
target_include_directories(${PROJECT_NAME}
    PUBLIC
        ${TORCH_INCLUDE_DIRS}
        ${OpenCV_INCLUDE_DIRS}
)


include(GNUInstallDirs)
install(TARGETS SimpleImplWithLibTorch
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
